package info.techgeek.labs.polymorphism;

public class FastJavaFast {
	public void test() {
	    for (int i = 0; i < 1000 * 1000 * 1000; i++) {
	      test2();
	    }
	  }
	 
	  public void test2() {
	    for (int i = 0; i < 1000 * 1000 * 1000; i++) {
	      test3();
	    }
	  }
	 
	  public void test3() {
	    for (int i = 0; i < 1000 * 1000 * 1000; i++) {
	      foo();
	    }
	  }
	 
	  // this is a "virtual" method, in the C++ sense
	  public void foo() {
	  }
	 
	  public static void main(String[] args) {
		  System.out.println("Begin ");
	    FastJavaFast fast = new FastJavaFast() {
	      // I am overriding the foo() method
	      public void foo() {
	        // do nothing
	      }
	    };
	    long time = System.currentTimeMillis();
	    fast.foo();
//	    fast.test3();
//	    fast.test2();
	    fast.test();
	    time = System.currentTimeMillis() - time;
	    System.out.println("time = " + time);
	  }

}
